package ru.st.selenium;

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.testng.*;
import org.testng.annotations.*;

import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

import ru.st.selenium.model.Film;
import ru.st.selenium.model.User;

public class AddMovie extends ru.st.selenium.pages.TestBase {
	  @BeforeMethod
	  public void mayBeLogout() {
	    if (app.getUserHelper().isNotLoggedIn()) {
	      return;
	    }
	    app.getUserHelper().logout();
	  }
	  
	  @Test
	  public void addMovieOK() throws Exception {
	    User user = new User().setLogin("admin").setPassword("admin");
	    app.getUserHelper().loginAs(user);	    
	    
	    app.getNavigationHelper().gotoAddMoviePage();
	    Film film = new Film().setTitle("Winner").setYear("2015");
	    app.getFilmHelper().create(film);	    
	  }
	  
	  @Test
	  public void addMovieFailed() throws Exception {
	    User user = new User().setLogin("admin").setPassword("admin");
	    app.getUserHelper().loginAs(user);	    
	    
	    app.getNavigationHelper().gotoAddMoviePage();
	    Film film = new Film().setTitle("Winner");
	    app.getFilmHelper().create(film);	    
	  }
	  
}
